<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>电影信息管理页面</title>
<link rel="stylesheet" type="text/css" href="/static/jquery-easyui-1.3.3/themes/default/easyui.css" />
<link rel="stylesheet" type="text/css" href="/static/jquery-easyui-1.3.3/themes/icon.css" />
<script type="text/javascript" src="/static/jquery-easyui-1.3.3/jquery.min.js"></script>
<script type="text/javascript" src="/static/jquery-easyui-1.3.3/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/static/jquery-easyui-1.3.3/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript">

	var url;
	
	function searchFilm(){
		$("#dg").datagrid("load",{
			"name":$("#s_name").val()
		});
	}
	
	function formatHot(val,row){
		if(val==1){
			return "是";
		}else{
			return "不是";
		}
	}

	function formatImageName(val,row){
		return "<img width=100 height=100 src='/static/filmImage/"+val+"'/>";
	}
	
	function deleteFilm(){
		var selectedRows=$("#dg").datagrid("getSelections");
		if(selectedRows.length==0){
			$.messager.alert("系统提示","请选择要删除的数据！");
			return;
		}
		var strIds=[];
		for(var i=0;i<selectedRows.length;i++){
			strIds.push(selectedRows[i].id);
		}
		var ids=strIds.join(",");
		$.messager.confirm("系统提示","您确定要删除这<font color=red>"+selectedRows.length+"</font>条数据吗？",function(r){
			if(r){
				$.post("/admin/film/delete",{ids:ids},function(result){
					if(result.success){
						$.messager.alert("系统提示","数据已成功删除！");
						$("#dg").datagrid("reload");
					}else{
						$.messager.alert("系统提示",result.errorInfo);
					}
				},"json");
			}
		});
	}
	
	function openFilmModifyTab(){
		var selectedRows=$("#dg").datagrid("getSelections");
		if(selectedRows.length!=1){
			$.messager.alert("系统提示","请选择一条要修改的电影！");
			return;
		}
		var row=selectedRows[0];
		window.parent.openTab('修改电影','modifyFilm.html?id='+row.id,'icon-modifyFilm');
	}
	
</script>
</head>
<body style="margin: 1px">
<table id="dg" title="电影信息管理" class="easyui-datagrid" 
   fitColumns="true" pagination="true" rownumbers="true" 
   url="/admin/film/list" fit="true" toolbar="#tb">
	<thead>
		<tr>
			<th field="cb" checkbox="true" align="center"></th>
			<th field="id" width="20" align="center">编号</th>
			<th field="imageName" width="50" align="center" formatter="formatImageName">电影图片</th>
			<th field="name" width="100" align="center">电影名称</th>
			<th field="title" width="200" align="center">帖子标题</th>
			<th field="hot" width="50" align="center" formatter="formatHot">热门?</th>
			<th field="publishDate" width="150" align="center">发布日期</th>
	</thead>
</table>
<div id="tb">
  <div>
    <a href="javascript:openFilmModifyTab()" class="easyui-linkbutton" iconCls="icon-edit" plain="true">修改</a>
	<a href="javascript:deleteFilm()" class="easyui-linkbutton" iconCls="icon-remove" plain="true">删除</a>	
  </div>
  <div>
  	&nbsp;电影名称：&nbsp;<input type="text" id="s_name" size="20" onkeydown="if(event.keyCode==13) searchFilm()"/>
  	<a href="javascript:searchFilm()" class="easyui-linkbutton" iconCls="icon-search" plain="true">搜索</a>
  </div>
</div>

</body>
</html>